package com.contract.spirit.ui.webview;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.util.Log;

import com.blankj.utilcode.util.ToastUtils;
import com.tencent.smtt.sdk.DownloadListener;


/**
 * Created by Ace on 2018/5/11.
 */

public class MyWebViewDownLoadListener implements DownloadListener {
    Context context;

    public MyWebViewDownLoadListener(Context context) {
        super();
        this.context = context;
    }

    @Override
    public void onDownloadStart(String url, String userAgent,
                                String contentDisposition, String mimetype, long contentLength) {
        Log.i("BaiduXAdSDK",url +" "+userAgent+" "+contentDisposition+" "+mimetype+" "+contentLength);
        Uri uri = Uri.parse(url);
        try {
            Intent intent = new Intent(Intent.ACTION_VIEW, uri);
            context.startActivity(intent);
        } catch (Exception e) {
            ToastUtils.showLong("无法下载，请确认下载链接正确");
        }
    }
}
